Changes

Jump to navigation Jump to search

Why an Order Was or Was Not Executed

2,368 bytes added, 13:45, 7 August 2019
It is a 's common situation when for a customer expects to expect an order to be generated and executed or vice versa , not be generated and not to be executed at a particular place on a chart. Combination A combination of the 2 following methods of studying nature of fillment should help you understand why an order was filled or non-fillment of orders sent from MultiCharts not during auto trading should help you in understanding the situation.
==Order and Position Tracker==
If an order was generated and sent from the script to a broker plugin, it is displayed in the Order and Position Tracker on the Orders tab. If an order is filled , you can see it 's execution price and details (see [[Order and Position Tracker|Orders Tab]]).
<br>
There are 2 possible reasons why an order is not placed at the broker:# The order was '''rejected''' either by MultiCharts, or by the broker (in most cases , you can find the reason of for rejection on in the Logs tab of the Order and Position Tracker (see [[Order and Position Tracker|Logs Tab]]) # The order was '''cancelled''' from the script. According to EasyLanaguagethe logic of EasyLanguage/PowerPowerLanguage, an order will be maintained as long as the conditions for its generation are met on each calculation. Once a condition is not met, it will be cancelled.
<br>
==Monitoring from Script==
This method is extremely usefull useful not only for backtesting, since the Order and Position Tracker has nothing in common with the process of historical calculationprocess, but also for live auto trading because you can see the strategy logic printed out in real-time.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 is your order is triggered in the code:
<br>
<br>
'''Var: Scale(0);'''<br> '''Condition1 = close > close[1];'''<br> '''If MinMove < 10 then'''<br> '''Scale = 1;'''<br>'''If MinMove > 99 and MinMove < 1000 then'''<br> '''Scale = 2;'''<br>'''If MinMove > 999 and MinMove < 10000 then'''<br>'''Scale = 3;'''<br>'''If MinMove > 9999 and MinMove < 100000 then'''<br>'''Scale = 4;'''<br>'''If MinMove > 99999 and MinMove < 1000000 then'''<br>'''Scale = 5;'''<br>  '''If Condition1 = true then begin'''<br>'''print("======================", NewLine,'''<br>'''"The date is :", DateToString(DateToJulian(Date)), ", ", NewLine,'''<br>'''"time is : ", TimeToString(ELTimeToDateTime(TimeTime_s)), ", ", NewLine,'''<br>'''"bar # is : ", maxbarsback+currentbar-1, ", ", 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, ", here a LIMIT/STOP ", NewLine,'''<br>'''"Condition1 is true, so at close of this bar the limit order to BUY/SELL buy at: ", NumToStr(close,scale), " is generated by the script ", NewLine,'''<br> '''"to be executed at bar #: ", maxbarsback+currentbar+1, NewLine,'''<br>'''"Bar Status is: "100 price , barstatus(example1)");'''<br>'''Buy next bar at close limit;'''<br><div style="background-color: #E5F6FF;">'''Exampleend else begin''': ...<br>If condition1 '''print( "===================== true and condition2 = false then begin", NewLine,'''<br>print('''"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: ", maxbarsback+currentbar-1high, ",", NewLine,'''<br>'''"current bar low is: ", low, ",", NewLine,'''<br>'''"current bar close is: ", close, ", ", NewLine,'''<br>'''"market position on chart is: ", i_marketpositionMarketPosition, ", ", NewLine,'''<br>'''"market position at broker is: ", MarketPosition_at_Broker, ",", i_MarketPosition_at_BrokerNewLine, '''<br>'''"Condition1 is false, here a LIMIT/STOP so no order to BUY/SELL is generated by the script at .", NewLine,'''<br>'''"100 priceBar Status is: ", barstatus(1));'''<br>sellshort next bar at 100 limit'''end;'''<br>end;</div>
<br>
<div style="background-color: #E3FBE5;">'''Note''':If the script is applied to your chart and it is opened in PowerLanguage Editorusing more than one data series, you will be able to see specify the following line in the Output tab:DataNum for [[BarStatus]].</div>
<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:
<br>
''======================<br>''The date is 0310/8/2013,<br>''time is 4:00:00 PM,<br>''bar # is 995.0700,<br>''current bar open is 865.32,<br>''current bar high is 865.98,<br>''current bar low is 851.63,<br>''current bar close is 853.67,<br>''market position on chart is 1.00,<br>''market position at broker is 0.00,<br>''Condition1 is false, so no order is generated.2012<br>''======================<br>''The date is 10/9/2013, <br>''time is 184:4500:00PM, <br>''bar # is 4362 996.00, <br>''current bar open is 856.28,<br>''current bar high is 862.65,<br>''current bar low is 842.98,<br>''current bar close is 855.86,<br>''market position on chart is 1.00, <br>''market position at broker is 10.00, here a LIMIT <br>''Condition1 is true, so at close of this bar the limit order to SELL buy at 855.9 is generated by the script at 100 price<br>''' to be executed at bar # 997.00<br>
[[Category:FAQ]]

Navigation menu