Problems with Brokersync
Posted: Mar 26 2015
I was long on „DD“ and wrote an Exitstrategy.
After I came back I was surprised with this.
Can someone pls help me explain what is wrong with my code so this will not happen again?
There is no entry signal so why did it enter a position?
After I came back I was surprised with this.
Can someone pls help me explain what is wrong with my code so this will not happen again?
There is no entry signal so why did it enter a position?
Code: Select all
inputs:
AtrLen(20),
AtrMultiTarget(2),
AtrMultiLoss(4);
variables:
Menge(0),
ProfitTargetSumme(0),
StoppLossSumme(0),
iiatr(0),
TPPreis(0),
SLPreis(0);
Menge=MarketPosition_at_Broker;
//BrokerSync
if marketposition=0 then
ChangeMarketPosition(Menge,AvgEntryPrice_at_Broker);
iiatr=AvgTrueRange(AtrLen);
//Exitbedingung
condition50=c>o;
condition51=c<o;
// SL TP berechnen
ProfitTargetSumme=Menge*AtrMultiTarget*iiatr;
StoppLossSumme=Menge*AtrMultiLoss*iiatr;
SetStopPosition;
SetProfitTarget(ProfitTargetSumme);
SetStopLoss(StoppLossSumme);
TPPreis=AvgEntryPrice_at_Broker+AtrMultiTarget*iiatr;
SLPreis=AvgEntryPrice_at_Broker-AtrMultiLoss*iiatr;
//Exit
if marketposition=1 then
begin
if condition50 then
sell next bar at market;
end;
if marketposition=-1 then
begin
if condition51 then
buytocover next bar at market;
end;
Print(" Datum ",date," Menge ",Menge, " MarketPosition_at_Broker ", MarketPosition_at_Broker,
" EntryPreis ",AvgEntryPrice_at_Broker," TP ",ProfitTargetSumme," StoppLossSumme ",StoppLossSumme,
" TPPreis ",TPPreis," SLPreis ",SLPreis );