Rejoindre la communauté
banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Comment ouvrir une position en fonction du Pivot Principale (Sans s'occuper des autres niveaux ?)

  • arka3579

    Juste ouvrir a l'achat si AU DESSUS DU PIVOT
    et l 'inverse pour la vente.
    J'arrive pas a programmer la condition.

    Help.
    J'y arrive vraiment pas. )=

    Voici le Robot de base.

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ //--- Inputs input string IndicatorName="MyEA_%Scalper"; extern bool POWER_ON = true; extern bool TRAIL_ON = true; input int Magic = 1; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; extern bool MICLOT_ON = false; extern double MicLot = 0.01; extern bool P_RISK_ON = TRUE; extern double Risk = 0.1; extern ENUM_TIMEFRAMES Filter_TF = PERIOD_M15; extern double Martingale_X = 2; extern double TS_ATR = 1.4; extern double SL_ATR = 4.4; extern double TP_ATR = 9.9; input int MA_Mode = 3; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma input int MA_Filter_Mode = 3; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int MA_OpenFast = 8; extern int MA_OpenSlow = 50; extern int MA_OpenFilter = 50; extern int MFI_Period = 9; extern int Volum = 20; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern int Start_Hour = 0; extern int End_Hour = 24; extern bool Monday = true; extern bool Tuesday = true; extern bool Wednesday = true; extern bool Thursday = true; extern bool Friday = true; extern bool Sunday = false; //+------------------------------------------------------------------+ bool DaytoTrade(){ bool daytotrade = false; if(DayOfWeek() == 0 && Sunday) daytotrade = true; if(DayOfWeek() == 1 && Monday) daytotrade = true; if(DayOfWeek() == 2 && Tuesday) daytotrade = true; if(DayOfWeek() == 3 && Wednesday) daytotrade = true; if(DayOfWeek() == 4 && Thursday) daytotrade = true; if(DayOfWeek() == 5 && Friday) daytotrade = true; return(daytotrade);} int OrderOpRetry=5; bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit, profitnow; bool Trail(){ bool trail = false; if(TRAIL_ON) trail = true; return(trail);} bool MICLot(){ bool micL = false; if(MICLOT_ON) micL = true; return(micL);} bool PercentR(){ bool PersR = false; if(P_RISK_ON) PersR = true; return(PersR);} //+------------------------------------------------------------------+ //| My TrailingStop | //+------------------------------------------------------------------+ void Trailingstop() { if (Trail()) double MyPoint = (iATR(NULL,PERIOD_CURRENT,14,0)*TS_ATR) ; for(int i=OrdersTotal()-1; i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) if(OrderMagicNumber()==Magic) if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>MyPoint) if(OrderStopLoss()<Bid-MyPoint) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(MyPoint),OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>MyPoint) if(OrderStopLoss()>Ask+MyPoint) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(MyPoint),OrderTakeProfit(),0,clrNONE); } } } //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //--- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //--- return orders volume if(buys>0) return(buys); else return(-sells); } //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { // Martingale %R double Lot1 = (AccountEquity()/100*Risk/100); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot1 = (AccountEquity()/100*Risk/100); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot1 = Martingale_X*last_lot; if( last_profit > 0 ) Lot1 = (AccountEquity()/100*Risk/100); // Martingale MicLot double Lot2 = MicLot; if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot2 = MicLot; else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot2 = Martingale_X*last_lot; if( last_profit > 0 ) Lot2 = MicLot; string ls_01 = " Levier: " + AccountLeverage() + "\n" + "\n" + " Heure du Server: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + "\n"; string ls_02 = "-------------------------------------\n"+"\n"; string ls_07 = " Solde : " + AccountBalance() + "\n"; string ls_08 = " Equity : " + AccountEquity() + "\n"; string ls_09 = " Account Profits : " + AccountProfit() + "\n"; string ls_10 = " Symbol : " + Symbol() + " " + OrderProfit() + "\n"; Comment( ls_01 + ls_02 + ls_07 + ls_08 + ls_09 + ls_10 ); int res; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(TP_ATR==0)tpb=0;else tpb=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*TP_ATR; if(TP_ATR==0)tps=0;else tps=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*TP_ATR; //--- get Moving Average //--- Pivot Points double xOpen=iOpen(NULL,Filter_TF,1); double xClose= iClose(NULL,Filter_TF,1); double xHigh = iHigh(NULL,Filter_TF,1); double xLow=iLow(NULL,Filter_TF,1); double xPP=(xHigh+xLow+xClose)/3; double xRange=xHigh-xLow; if (((iMFI(NULL,0,MFI_Period,0) > 60) && (iMFI(NULL,0,MFI_Period,0) < 100))) if (Bid < (xHigh+xLow+xClose)/3) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_SELL,Lot1,Bid,3,slb,tpb,Sell_Com+Magic,Magic,0,Red); if (MICLot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,slb,tpb,Sell_Com+Magic,Magic,0,Red); return; } //--- BUY conditions if (((iMFI(NULL,0,MFI_Period,0) < 40) && (iMFI(NULL,0,MFI_Period,0) > 0))) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_BUY,Lot1,Ask,3,slb,tpb,Buy_Com+Magic,Magic,0,Blue); if (MICLot()) res=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com+Magic,Magic,0,Blue); return; } } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else Trailingstop(); } //+------------------------------------------------------------------+ // Martingale //+------------------------------------------------------------------+ double last_history_profit() { double cpte_profit = 0; //int Magik_No = -1; if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) ) { if( OrderMagicNumber() == Magic ) { last_profit = OrderProfit(); last_lot = OrderLots(); last_tip = OrderType(); } } return(0); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,0,14,1); return(ATR); } //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); }
  • arka3579

    Le pivot sera utiliser en M15 sur Graph M1
    (Je précise)
    Merci pour votre aide.

    aRka.
  • christrading — en réponse à arka3579 dans son message #127033

    c'est interessant votre propos, pouvez vous me donné une petite explication s'il vous plait?
  • arka3579

    Bonjour, Christrading, sauf erreur de ma part il a été démontrer que si le prix ouvrait au dessus de Point-Pivot le court en général montait un certain temps, ainsi j'aimerai par exemple que l'ouverture de ma position "LONG" se face a la condition d'être au dessus de ce dernier. et SHORT si en dessous du P.P.
    Dans le cas présent il s'agit plus spécifiquement de scalping Pivot M15 sur graph 1 minutes.

    Merci par avance pour les lignes de codes.

    aRka.
  • arka3579

    Je pense que c'est bon, mais faudrait vérifier.
    Mon MT4 me joue des tours je crois.

    Code
    double orderPrice = OrderOpenPrice(); double Pivot = (((iHigh ( Symbol (), TF_Filter , iHighest ( Symbol (), TF_Filter , MODE_HIGH, 1 , 1 ))) + (iLow ( Symbol (), TF_Filter , iLowest ( Symbol (), TF_Filter , MODE_LOW, 1 , 1 ))) + Close[0]) / 3); //--- SELL conditions if( Bid <= Pivot) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_SELL,Lot1,Bid,3,sls,tps,Sell_Com+Magic,Magic,0,Red); if (MICLot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com+Magic,Magic,0,Red); return; } //--- BUY conditions if( Ask >= Pivot) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_BUY,Lot1,Ask,3,slb,tpb,Buy_Com+Magic,Magic,0,Blue); if (MICLot()) res=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com+Magic,Magic,0,Blue); return; } } //+------------------------------------------------------------------+ // GetBuyOrderCount() // returns the number of open buy orders //+------------------------------------------------------------------+ int GetBuyOrderCount() { int count=0; for (int k = OrdersTotal();k >=0 ;k--) { if (OrderSelect(k, SELECT_BY_POS)) { if (OrderType()==OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { count=count+1; } } } return count; } //+------------------------------------------------------------------+ // GetSellOrderCount() // returns the number of open sell orders //+------------------------------------------------------------------+ int GetSellOrderCount() { int count=0; // find all open orders of today for (int k = OrdersTotal(); k >=0 ;k--) { if (OrderSelect(k, SELECT_BY_POS)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { count=count+1; } } } return count; }

    Bonne journée.
    aRka