+1 888 340 6572

Why an Order Was or Was Not Executed: Difference between revisions

From MultiCharts
Line 15: Line 15:
Adding the following line under the same conditions right before the line, when generating your buy/sell orders, will help you to understand at what particular bar, when, and at what price your order is triggered in the code:
Adding the following line under the same conditions right before the line, when generating your buy/sell orders, will help you to understand at what particular bar, when, and at what price your order is triggered in the code:
<br>
<br>
<br>
Var: Scale(0); <br>  
'''Var: Scale(0);'''
Condition1 = close > close[1]; <br>  
<br>  
If MinMove < 10 then <br>  
'''Condition1 = close > close[1];'''
Scale = 1; <br>
<br>  
If MinMove > 99 and MinMove < 1000 then <br>  
'''If MinMove < 10 then'''<br>  
Scale = 2; <br>
'''Scale = 1;'''<br>
If MinMove > 999 and MinMove < 10000 then <br>
'''If MinMove > 99 and MinMove < 1000 then'''<br>  
Scale = 3; <br>
'''Scale = 2;'''<br>
If MinMove > 9999 and MinMove < 100000 then <br>
'''If MinMove > 999 and MinMove < 10000 then'''<br>
Scale = 4; <br>
'''Scale = 3;'''<br>
If MinMove > 99999 and MinMove < 1000000 then <br>
'''If MinMove > 9999 and MinMove < 100000 then'''<br>
Scale = 5; <br> If Condition1 = true then begin <br>
'''Scale = 4;'''<br>
print( "======================", NewLine, <br>
'''If MinMove > 99999 and MinMove < 1000000 then'''<br>
"The date is:", DateToString(DateToJulian(Date)), ",", NewLine, <br>
'''Scale = 5;'''<br>  
"time is: ", TimeToString(ELTimeToDateTime(Time_s)), ",", NewLine, <br>
 
"bar # is: ", maxbarsback+currentbar, ",", NewLine, <br>
'''If Condition1 = true then begin'''<br>
"current bar open is: ", open, ",", NewLine, <br>
'''print( "======================", NewLine,'''<br>
"current bar high is: ", high, ",", NewLine, <br>
'''"The date is:", DateToString(DateToJulian(Date)), ",", NewLine,'''<br>
"current bar low is: ", low, ",", NewLine, <br>
'''"time is: ", TimeToString(ELTimeToDateTime(Time_s)), ",", NewLine,'''<br>
"current bar close is: ", close, ",", NewLine, <br>
'''"bar # is: ", maxbarsback+currentbar, ",", NewLine,'''<br>
"market position on chart is: ", MarketPosition, ",", NewLine, <br>
'''"current bar open is: ", open, ",", NewLine,'''<br>
"market position at broker is: ", MarketPosition_at_Broker, ",", NewLine, <br>
'''"current bar high is: ", high, ",", NewLine,'''<br>
"Condition1 is true, so at close of this bar the limit order to buy at: ", NumToStr(close,scale), " is generated by the script", NewLine, <br>  
'''"current bar low is: ", low, ",", NewLine,'''<br>
"to be executed at bar #: ", maxbarsback+currentbar+1, NewLine, <br>
'''"current bar close is: ", close, ",", NewLine,'''<br>
"Bar Status is: ", barstatus(1)); <br>
'''"market position on chart is: ", MarketPosition, ",", NewLine,'''<br>
Buy next bar at close limit; <br>
'''"market position at broker is: ", MarketPosition_at_Broker, ",", NewLine,'''<br>
end else begin <br>
'''"Condition1 is true, so at close of this bar the limit order to buy at: ", NumToStr(close,scale), " is generated by the script", NewLine,'''<br>  
print( "======================", NewLine, <br>
'''"to be executed at bar #: ", maxbarsback+currentbar+1, NewLine,'''<br>
"The date is: ", DateToString(DateToJulian(Date)), ",", NewLine, <br>
'''"Bar Status is: ", barstatus(1));'''<br>
"time is: ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine, <br>
'''Buy next bar at close limit;'''<br>
"bar # is: ", symbol_currentbar, ",", NewLine, <br>
"current bar open is: ", open, ",", NewLine, <br>
"current bar high is: ", high, ",", NewLine, <br>
"current bar low is: ", low, ",", NewLine, <br>
"current bar close is: ", close, ",", NewLine, <br>
"market position on chart is: ", MarketPosition, ",", NewLine, <br>
"market position at broker is: ", MarketPosition_at_Broker, ",", NewLine, <br>
"Condition1 is false, so no order is generated.", NewLine, <br>
"Bar Status is: ", barstatus(1)); <br>
end; <br>  


'''end else begin'''<br>
'''print( "======================", NewLine,'''<br>
'''"The date is: ", DateToString(DateToJulian(Date)), ",", NewLine,'''<br>
'''"time is: ", TimeToString(ELTimeToDateTime(Time)), ",", NewLine,'''<br>
'''"bar # is: ", symbol_currentbar, ",", NewLine,'''<br>
'''"current bar open is: ", open, ",", NewLine,'''<br>
'''"current bar high is: ", high, ",", NewLine,'''<br>
'''"current bar low is: ", low, ",", NewLine,'''<br>
'''"current bar close is: ", close, ",", NewLine,'''<br>
'''"market position on chart is: ", MarketPosition, ",", NewLine,'''<br>
'''"market position at broker is: ", MarketPosition_at_Broker, ",", NewLine,'''<br>
'''"Condition1 is false, so no order is generated.", NewLine,'''<br>
'''"Bar Status is: ", barstatus(1));'''<br>
'''end;'''<br>
<br>
<div class="note">If using more than one data series, specify the DataNum for [[BarStatus]].</div>
<div class="note">If using more than one data series, specify the DataNum for [[BarStatus]].</div>
<br>
<br>
If the script is applied to your chart and it is opened in the PowerLanguage Editor, you will be able to see the following lines in the Output tab:
If the script is applied to your chart and it is opened in the PowerLanguage Editor, you will be able to see the following lines in the Output tab:
<br>
<div class="example-no-title">
''======================<br>
''The date is 10/8/2013,<br>
''The date is 10/8/2013,<br>
''time is 4:00:00 PM,<br>
''time is 4:00:00 PM,<br>
Line 76: Line 69:
''market position on chart is  1.00,<br>
''market position on chart is  1.00,<br>
''market position at broker is  0.00,<br>
''market position at broker is  0.00,<br>
''Condition1 is false, so no order is generated.<br>
''Condition1 is false, so no order is generated.</div>
''======================<br>
<div class="example-no-title">
''The date is 10/9/2013,<br>
''The date is 10/9/2013,<br>
''time is 4:00:00 PM,<br>
''time is 4:00:00 PM,<br>
Line 88: Line 81:
''market position at broker is  0.00,<br>
''market position at broker is  0.00,<br>
''Condition1 is true, so at close of this bar the limit order to buy at 855.9 is generated by the script<br>
''Condition1 is true, so at close of this bar the limit order to buy at 855.9 is generated by the script<br>
''to be executed at bar #  997.00<br>
''to be executed at bar #  997.00</div>


[[Category:FAQ]]
[[Category:FAQ]]
[[Category:Strategy Trading]]
[[Category:Strategy Trading]]