I have a question regarding setting a Stop Loss and Profit Target once I am in a trade.
If I enter a trade I do not want to exit on a Stop and Reverse signal. I only want to exit on a trigger of a Stop Loss or a Trigger of a Profit Target.
Therefore when I do a "Session" and check the Trade by Trade report all I should see in the Entry Name is "SellEntry" and "BuyEntry" as per the code and all I should see in the Exit Name is "LongStop", "LongTarget", "ShortStop" and "ShortTarget".
However what happens is I might exit on a Long Target then the system enters the next trade on a Long Stop.
My attempted Code is below just using a Moving Average crossover for entry. The exits are based on ATR (I have left out the set up part of the code). The Stop Loss might be Entry minus 2xATR and the Profit Target might be ENtry plus 4xATR as an example.
'Search for a Long Entry Signal If CrossesOver(ShortAve,LongAve) Then Buy("BuyEntry",1,0,Market,Day) End If
'Set Long Target If Close>LongTarget Then Sell("LongTarget",1,0,Limit,Day) End If 'Set Long Stop If Close
'Search for a Short Entry Signal If CrossesUnder(ShortAve,LongAve) Then Sell("SellEntry",1,0,Market,Day) End If
'Set Short Target If Close 'Set Short Stop If Close>ShortStop Then Buy("ShortStop",1,0,Market,Day) End If
I need to ensure that once I enter a trade either long or short that the "Session" only acts on one of the exit options and only then moves on to look for an entry using the Moving Avergae crossover.
Can you offer any suggestions. Sorry but I have had no experience in programming before and have been struggling with what seems a simple setup for 2 weeks now.
Thanks. |