//+------------------------------------------------------------------+//| Order Enter Function | //<< When this was getting called it was conducting all the mathematical formula's irrespective of the pending order!//+------------------------------------------------------------------+void OrderEntry(int direction)
{
//Padding for the stop and padding for the entry too. double ATR_Pad = iATR(NULL,60,14,1)/2;
double Buy_Pad = NormalizeDouble(ATR_Pad,Digits);
double Sell_Pad = NormalizeDouble(ATR_Pad,Digits);
//Get Highest Price in our lookback range and set buy price above it.int iTBT = iBarShift(NULL,60, triggerBarTime, true),
iHH = iHighest(NULL,60, MODE_HIGH, iTBT + CandlesBeforeBiasObtained, 0);
double Buy_Here = High[iHH] + Buy_Pad;
double buyPrice= NormalizeDouble(Buy_Here,Digits);
//Get Lowest Price in our lookback range and set sell price below it.int iTBT_1 = iBarShift(NULL, 60, triggerBarTime, true),
iLL = iLowest(NULL, 60, MODE_LOW, iTBT_1 + CandlesBeforeBiasObtained, 0);
double Sell_Here=Low[iLL] - Sell_Pad;
double sellPrice= NormalizeDouble(Sell_Here,Digits);
//Stop calculations. double ATR = iATR(NULL,60,14,1);
double MA = iMA(NULL,60,MA_Period,0,1,0,1);
double BuyStopPriceMath = MA - ATR;
double SellStopPriceMath = MA + ATR;
double BuyStopPrice = NormalizeDouble(BuyStopPriceMath,Digits);
double SellStopPrice = NormalizeDouble(SellStopPriceMath,Digits);
//get our buystop price from below the ma and our takeprofit based on our r:r ratio.double pips_to_bsl=buyPrice-BuyStopPrice;
double buy_tp_price=(pips_to_bsl*RewardRatio)+buyPrice;
double buy_takeprofit_price= NormalizeDouble(buy_tp_price, Digits);
//get our sellstop price from below the ma and our takeprofit based on our r:r ratio.double pips_to_ssl=SellStopPrice-sellPrice;
double sell_tp_price=sellPrice-(pips_to_ssl*RewardRatio);
double sell_takeprofit_price= NormalizeDouble(sell_tp_price, Digits);
//Lot calculation - Facilitates Notional and Lots within MT4 - As well as find the tick value relative to the account denomination. double risk_amount = AccountEquity( )*RiskPercent/100;
double Lot_Step = MarketInfo(Symbol(), MODE_LOTSTEP);
double ts = MarketInfo(Symbol(), MODE_TICKSIZE);
double tv = MarketInfo(Symbol(), MODE_TICKVALUE);
double minlot = MarketInfo(Symbol(), MODE_MINLOT);
double loss_for_1_lot = pips_to_bsl/ ts * tv ;
//Alert(loss_for_1_lot);double LotSize_Buy = MathFloor( risk_amount / loss_for_1_lot/ Lot_Step) * Lot_Step ;
//Alert(LotSize_Buy);double loss_for_1_lot1 = pips_to_ssl/ ts * tv ; //<<<<<<<<<<<<<<<<<<<< THIS WAS RUNNING THE EQUATION EVEN THOUGH IT WAS NOT REQUIRED!
//Alert(loss_for_1_lot1); //<<<<<<<<<<<<<<<<<<< THIS IS NOW MOVED TO WITHIN THE PARENTHESIS "DIRECTION == 1". double LotSize_Sell = MathFloor( risk_amount / loss_for_1_lot1/ Lot_Step) * Lot_Step ;
//Alert(LotSize_Sell);//+-------------------------------------------------------------------------------------+//| Order Buy Function |//+-------------------------------------------------------------------------------------+ //Place a pending buystop if no orders exists. Pending or otherwise.if(direction==0)
{
...
} // end of if(direction==0)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //+---------------------------------------------------------------------------------------+//|Order Sell Function |//+---------------------------------------------------------------------------------------+ if(direction==1)
{//--Sell--//
...
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Yea あなたがそれを強調したので、私はそれを見ていました、ありがとうございます!。私は、具体的に数式全体を分解して(これをするように言われているのは知っています!)、それが間違っている場所にそれをフォローダウンするつもりです。今のところ、なぜpips_to_sslに "0 "が出力されるのか理解できません。このゼロ除算が 出力されるバックテストのセクションの保留中の注文にさえ使われていないのに...。
0」を表示しているのはpips_to_bslではありません...。おかしいなぁ...。
OK 私はそれを修正し、問題を解決したと思う - 私はちょうどプロンプトで私を助けるために皆に感謝したい!本当に感謝します :D!
だから基本的にこれは間違っていたようです - メモは以下のとおりです - 私は今、彼らがあるべき場所にBUYSTOPSとSELLSTOPSに対応する関連するコードを移動しました!私は、それが間違っていたことを確認するために、私はそれを行うことができます。