IF c6 AND c7 AND c8 AND c9 and OTD THEN
SELLSHORT 10 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator10 = MACDline[12,26,9](close)
c10 = (indicator10 <= -0.0015)
IF c10 THEN
EXITSHORT AT MARKET
ENDIF
No matter the origin, if you code like that (above), it becomes unreadable for yourself. Also, the result will be unpredictable (which is almost the same ;-)).
// Conditions to exit short positions
indicator10 = MACDline[12,26,9](close)
c10 = (indicator10 <= -0.0015)
IF c6 AND c7 AND c8 AND c9 and OTD THEN
SELLSHORT 10 CONTRACT AT MARKET
ELSIF c10 THEN
EXITSHORT AT MARKET
ENDIF
If you code like the above, you depict mutual exclusive situations, which with the first example are not mutually exclusive at all.
A bit more tightly coded would be like this :
IF c6 AND c7 AND c8 AND c9 and OTD THEN
SELLSHORT 10 CONTRACT AT MARKET
ELSE
// Conditions to exit short positions
indicator10 = MACDline[12,26,9](close)
c10 = (indicator10 <= -0.0015)
If c10 THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
But this still would leave you with all kind of doubts, and it should be like this :
If Not OnMarket then
EnteredMarket = 0
If Not EnteredMarket then // Superfluous here, but good habit.
// Conditions to go Short.
IF c6 AND c7 AND c8 AND c9 and OTD THEN
SELLSHORT 10 CONTRACT AT MARKET
EnteredMarket = 1
ENDIF
ENDIF
If Not EnteredMarket then // Nit superfluous at all.
// Other conditions for going Short or ... Long.
IF ... then
// ...
EnteredMarket = 1
ENDIF
ENDIF
ENDIF // Not OnMarket ?
If Not EnteredMarket then // A bit of overkill, but in certain situations even this is good habit.
If ShortOnMarket then
// Conditions to exit short positions
indicator10 = MACDline[12,26,9](close)
c10 = (indicator10 <= -0.0015)
If c10 THEN
EXITSHORT AT MARKET
ENDIF
ENDIF // ShortOnMarket ?
ENDIF // Not EnteredMarket ?
This leaves no doubt about what is happening and “what you are doing”;
Try to rebuild the code like this and you may automatically run into the culprit(s) why it is not working out, even before running your re-coded program.
Never think this is long-winded and a waste of time, because clarity above all !
Good luck now !