Posts: 2
Please rate this topic Current rating: 0 Votes: 0
RSS
Hemanth Kumar
Hemanth Kumar
FREE Member
Offline
  • Registered: 12-13-17
  • Posts: 1
  • Age: 2020
  • Email
  • Thanks: 1

PSAR - (Tested with over $3,100,000 profit)

//+------------------------------------------------------------------+
//|                                                 EA-PSAR_v1-0.mq4 |
//|                                                    Luca Spinello |
//|                               
//+------------------------------------------------------------------+

#property copyright     "Luca Spinello - mql4tradingautomation.com"
#property version       "1.00"
#property strict
#property description   "This Expert Advisor opens orders when the PSAR changes from above to below the price or vice versa"
#property description   " "
#property description   "DISCLAIMER: This code comes with no guarantee, you can use it at your own risk"
#property description   "We recommend to test it first on a Demo Account"

/*
ENTRY BUY: PSAR changes from above the previous bar to below the current bar
ENTRY SELL: PSAR changes from below the previous bar to above the current bar
EXIT: Take profit or trailing stop using PSAR
*/


extern double LotSize=0.1;             //Position size

extern double StopLoss=20;             //Stop loss in pips
extern double TakeProfit=500;          //Take profit in pips

extern int Slippage=2;                 //Slippage in pips

extern bool TradeEnabled=true;         //Enable trade

extern double PSARStep=0.2;            //PSAR Step         
extern double PSARMaxStep=0.02;        //PSAR Max Step

extern int MagicNumber=11223344;       //Magic Number to assign to the orders

//Functional variables
double ePoint;                         //Point normalized

bool CanOrder;                         //Check for risk management
bool CanOpenBuy;                       //Flag if there are buy orders open
bool CanOpenSell;                      //Flag if there are sell orders open

int OrderOpRetry=10;                   //Number of attempts to perform a trade operation
int SleepSecs=3;                       //Seconds to sleep if can't order
int MinBars=60;                        //Minimum bars in the graph to enable trading

//Functional variables to determine prices
double MinSL;
double MaxSL;
double TP;
double SL;
double Spread;
int Slip;


//Variable initialization function
void Initialize(){         
   RefreshRates();
   ePoint=Point;
   Slip=Slippage;
   if (MathMod(Digits,2)==1){
      ePoint*=10;
      Slip*=10;
   }
   TP=TakeProfit*ePoint;
   SL=StopLoss*ePoint;
   CanOrder=TradeEnabled;
   CanOpenBuy=true;
   CanOpenSell=true;
}


//Check if orders can be submitted
void CheckCanOrder(){           
   if( Bars      Print("INFO - Not enough Bars to trade");
      CanOrder=false;
   }
   OrdersOpen();
   return;
}


//Check if there are open orders and what type
void OrdersOpen(){
   for( int i = 0 ; i < OrdersTotal() ; i++ ) {
      if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) {
         Print("ERROR - Unable to select the order - ",GetLastError());
         break;
      }
      if( OrderSymbol()==Symbol() && OrderType() == OP_BUY) CanOpenBuy=false;
      if( OrderSymbol()==Symbol() && OrderType() == OP_SELL) CanOpenSell=false;
   }
   return;
}


//Close all the orders of a specific type and current symbol
void CloseAll(int Command){
   double ClosePrice=0;
   for( int i = 0 ; i < OrdersTotal() ; i++ ) {
      if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) {
         Print("ERROR - Unable to select the order - ",GetLastError());
         break;
      }
      if( OrderSymbol()==Symbol() && OrderType()==Command) {
         if(Command==OP_BUY) ClosePrice=Bid;
         if(Command==OP_SELL) ClosePrice=Ask;
         double Lots=OrderLots();
         int Ticket=OrderTicket();
         for(int j=1; j<OrderOpRetry; j++){
            bool res=OrderClose(Ticket,Lots,ClosePrice,Slip,Red);
            if(res){
               Print("TRADE - CLOSE - Order ",Ticket," closed at price ",ClosePrice);
               break;
            }
            else Print("ERROR - CLOSE - error closing order ",Ticket," return error: ",GetLastError());
         }
      }
   }
   return;
}


//Open new order of a given type
void OpenNew(int Command){
   RefreshRates();
   double OpenPrice=0;
   double SLPrice;
   double TPPrice;
   if(Command==OP_BUY){
      OpenPrice=Ask;
      SLPrice=OpenPrice-SL;
      TPPrice=OpenPrice+TP;
   }
   if(Command==OP_SELL){
      OpenPrice=Bid;
      SLPrice=OpenPrice+SL;
      TPPrice=OpenPrice-TP;
   }
   for(int i=1; i<OrderOpRetry; i++){
      int res=OrderSend(Symbol(),Command,LotSize,OpenPrice,Slip,NormalizeDouble(SLPrice,Digits),NormalizeDouble(TPPrice,Digits),"",MagicNumber,0,Green);
      if(res){
         Print("TRADE - NEW - Order ",res," submitted: Command ",Command," Volume ",LotSize," Open ",OpenPrice," Slippage ",Slip," Stop ",SLPrice," Take ",TPPrice);
         break;
      }
      else Print("ERROR - NEW - error sending order, return error: ",GetLastError());
   }
   return;
}


//Technical analysis of the indicators
bool CrossToOpenBuy=false;
bool CrossToOpenSell=false;


void CheckPSARCross(){
   CrossToOpenBuy=false;
   CrossToOpenSell=false;
   double PSARCurr=iSAR(Symbol(),0,PSARStep,PSARMaxStep,0);
   double PSARPrev=iSAR(Symbol(),0,PSARStep,PSARMaxStep,1);
   if(PSARCurr<Close[0] && PSARPrev>Close[1]){
      CrossToOpenBuy=true;
   }
   if(PSARCurr>Close[0] && PSARPrev<Close[1]){
      CrossToOpenSell=true;
   }
}


//Trailing Stop with PSAR
void UpdatePositions(){

   //Scan the open orders backwards
   for(int i=OrdersTotal()-1; i>=0; i--){
   
      //Select the order, if not selected print the error and continue with the next index
      if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) {
         Print("ERROR - Unable to select the order - ",GetLastError());
         continue;
      }
     
      //Check if the order can be modified matching the criteria, if criteria not matched skip to the next
      if(OrderSymbol()!=Symbol()) continue;
      if(OrderMagicNumber()!=MagicNumber) continue;
     
      //Prepare the prices
      double TakeProfitPrice=OrderTakeProfit();
      double StopLossPrice=OrderStopLoss();
      double OpenPrice=OrderOpenPrice();
      double NewStopLossPrice=StopLossPrice;
      double NewTakeProfitPrice=TakeProfitPrice;
     
      //PSAR Value of the current symbol, current time frame , PSARStep, PSARMaxStep, previous candle
      double PSARPrice=iSAR(Symbol(),0,PSARStep,PSARMaxStep,1);
     
      //Get updated prices and calculate the new Stop Loss and Take Profit levels, these depends on the type of order
      RefreshRates();
      if(OrderType()==OP_BUY){
         if(PSARPrice>StopLossPrice && PSARPrice<Close[1] && PSARPrice<TakeProfitPrice){
            NewStopLossPrice=NormalizeDouble(PSARPrice,Digits);
         }
      }
      if(OrderType()==OP_SELL){
         if(PSARPriceClose[1] && PSARPrice>TakeProfitPrice){
            NewStopLossPrice=NormalizeDouble(PSARPrice,Digits);
         }
      }
     
      //If the new Stop Loss and Take Profit Levels are different from the previous then I try to update the order
      if(NewStopLossPrice!=StopLossPrice){
         Print("Modifying order ",OrderTicket()," Open Price ",OpenPrice," New Stop Loss ",NewStopLossPrice," New Take Profit ",NewTakeProfitPrice);
         if(OrderModify(OrderTicket(),OpenPrice,NewStopLossPrice,NewTakeProfitPrice,0,Yellow)){
            Print("Order modified");
         }
         else{
            Print("Order failed to update with error - ",GetLastError());
         }     
     
      }

   
   }
}




//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   //Calling initialization, checks and technical analysis
   Initialize();
   CheckCanOrder();
   UpdatePositions();
   CheckPSARCross();
   //Check of Entry/Exit signal with operations to perform
   if(CrossToOpenBuy){
      CloseAll(OP_SELL);
      if(CanOpenBuy && CanOrder) OpenNew(OP_BUY);
   }
   if(CrossToOpenSell){
      CloseAll(OP_BUY);
      if(CanOpenSell && CanOrder) OpenNew(OP_SELL);
   }
  }
//+------------------------------------------------------------------+

EA-PSAR_v1-0.ex4 15.2 kb, 69 downloads since 2017-12-13 

Thanked for the post: jozmik

EA Tester Team Manager
MT4talk Forex Robot Tester Team
Online
  • From: Ukraine
  • Registered: 09-08-18
  • Posts: 668
  • Gender: male
  • Age: 37
  • Email
  • Thanks: 146

Hi, thanks for sharing.

I updated this EA and I added an automatic lot size manager, which automatically grows the trading lot size as the trading balance is growing. Each time the robot makes a profit its starts trading with a bigger lot size. The profit talks for itself!

I made a lot of changes and tested this Forex robot on a real STP account!

Please look at what I got.

We tested on: FXOpen Broker!

img/p/fxopen.png

If you are using this Forex robot on any other forex broker, then you may have to find your own settings, because provided settings not working with all brokers.

We tested on super-fast Forex VPS! It's highly recommended for 24/5 automated trading!

img/vps.png

Deposit: $500
Leverage: 1:500
The test time: 3 months.
Total trades: 49
Average trades per month: 16
Total profit: $3,180,360

I tested on the real account!

img/m/25379/5f03bbb86b3ec4.60416935.gif

Note: We made this test for you, to give you a starting point. You should always make your own test.


Have a good trend and the biggest profit!

For detailed test information, please download the files below!


This test showed that this EA has potential. But all traders himself must optimize the EA on his account with many backtests and forward tests.

If you have any questions about this test you can contact me via email on my MT4talk profile page, at https://mt4talk.com/misc.php?email=25379
NOTE: Only MT4talk PRO members can contact me via email.

ea-psar v1.0 mod1.ex4 29.6 kb, 38 downloads since 2020-07-07 
gu m30 d500 p3.1M ea-par v1.0 mod1.htm 37.61 kb, 44 downloads since 2020-07-07 
gu m30 d500 p3.1M ea-par v1.0 mod1.set 1.35 kb, 41 downloads since 2020-07-07 
User's signature

- We are testing robots on FBS Forex broker!
- We are testing robots on FXopen accounts!
- We are testing robots on LQDFX accounts!

Online Users & Stats
  • Total number of registered users: 58,369
  • Registered users today: 3
  • Newest registered user: rovinb
  • Total number of topics: 11,580
  • Total number of posts: 37,793

Online users: 5,357 guests, 402 Members:

125034805, 71446087, Aab Wikamayana, Aamir Khan Shaizar, aarontorresorozco, Abd Salam Puteh, Abiodun2220, Abolfazle1234, Achmad, Ade, admin, AdriN, Agostino Visentini, Ahmad AA, ajmal@789, akuparlan, alan252626276256, Alanlan, alapia, AlexDu, Alexx, Aliabbasian, ali_sport, Ameen, amirbibres, amirkral98, Amit Namdeo, andrian25, angelhart, anwar, apofla, APPS, Arihant Baradiya, Arun Charan, Asaph Madimetja Chuene, ashhamm, Azar, azroy86, Bandara Sanath, bangmtok, Barkie, Baster, Bedille, believeme, BENEX, betuboxem, bhouse34, Bhruno Alex, billbroch, bonifaz, Boram, bra2abualrob, brodakwame, Buhbit, bxxlb001, Byron, c j, Camargo, cbocceda, chanachai.pha, charlenep1, Chí Linh Lee, chinokio, Chris nomzanga, cmaq, Constantin Sako, cosminb, crensburg, cris_77, crootster, CrustyOnion, dakahung, Damian Virenque, DanCanji, Dangersonicx, Dani Mata, danielshehayeb82, Darli, Darren Hunt, DashingDk, dave137, David Hoang, Davinder Gosal, daytraderx, dbruno, ddtrc, denizyaran, Dforex7, Dieseldes, Diki Ndimen, diskus66, dlpfxcapital, dnujj98, dogsbody, doukang2, dsggs, DunasMan, EA Tester Team Manager, ecosport1651, Elite12345, Emanuele Vazzoler, eme2000, Emil Botto, Emmanuel Eric Leung, Enekie, Enric Enguix, Enrique Lafuente, Ephraim, epifreak, Espinosa Alfonso, Eugen Schmidt, Ewan Burn, Ezra Calloway, Falk Reichardt, fane76, fibomen, Fleance, Francolegend, fredd, freddytm, fredericrigaud, fxfarmerashik, fxWaz, gasper, Gat76, gcanuwom, geertbloemen, GeorgGiortz, georofl, gerardocer, Giancarlo Cavaliere, GiggzMoraka, gilfx, gisoetsan, glanunkgood, Godfa7her, gonza42668a5, Grillmaster, Gumballone, Gurschwin, Gurumukh, Hackmiser, Hadibisnis., Hamza Batchi, Harnish K Patel, hasanrockefeller, Hayden Whitfield, Hd_yar, heitorp, helei, Hemal Sutaria, henrique, Hesam000, Hien.nv5, hoangko, Hossam, hussain66, Hyogi Yoshh, ian.kungu, ilml, indrakh, Inno Vation, Inokko, inovasiweb, ismail, Jaco Venter, James Ngande, Jane Do, Jattila688, jd1238, Jhon Jairo Nuñez Diaz, Jhsdo1, Jignesh Dholaria, Jimmymull1, Joel Corrand, Johan Ang, john21000, johncrichton001, johnwayneaussie, JOY, k3nshy, kallhox, kamal123, Kankam, kareemabbas90, Kaushal Shah, kaydahbiz, keithgrooves, khalid, kingd, Kir, kiramat, Kisakye Joseph, Knew, KnifeS2, kpmurugan7, ks1061, Kubilay Örnek, laco2019, Lazor Soon, lee, LEGAULOIS, Leocadio, leopar1972, Lidia Podila, Limiter, Lisseth, LPJAV57, luxuss777, maek35, maennicr, MahmoudAhmed, maleselasimon1, maniun, Marci, Marcus111, MarianNick123, mars7, MasiloM, maumau, maxheadroom, maxxyryo, Mduduzi Khwela, Mhinga, migz335, Mikael Bos, mike1809, Mino Cigna, MlleEsther, Mobi1520, Mogbolu Simeon, Mojaki, Moncy Pothen, MotherFather, Mthokoh789, MyForexT, Møĥãmêd Kâddøûř, Nathan Wilkes, Ncebo, neagoelaur, Neofx, Nevers Soleed Kanyamakina, nexthegreat, Nguyễn Duy Nguyên, noeltg, npataya, nxumalo663, obzajd, Omoakin, Onti23, Oobameleng, openmeta, oshilohc, pang3ran, paolocroci69, parallelnative, Patcharapon Jaithong, Paul103, pcalrose, peteaw72, petopfy, Phạm Ngọc Trí, Phatjoe, Phetedi Anold Marebane, Philcoms26, philiptes, Piero Aiello, posokhovall, Pouringwrm, Prava, PrinceB2020, proinv_1998, prs10ce, ptitdiim, puguhnw, Pwolfas, Qubik, qubil17, quintana, R A Raaj, rainer3770, Rama, ramlickatz, ravan, realbagoosh, Reitumetse Lobere, Reoratile, Rethabile, Rexhhhh, ReyRey, ricardoherminio, rodrigolivei, Rohan Patel, Rooks, Rori@12, rovinb, Sadaquat Sartaz, Sadid, sahmdt, Sai Hla Paing, salim07, Sam Tag, SAMI308, Samsron Jeong, Sanoevera, sasastephe, SchepJoop, Sean Kennedy, Sebek, Seelan Moodley, segaj, Selva Selva Ivak, sergeik, Seth76, SEVAAN, SGR, Shafiqyuno, Shaiful Azman, shamsuriyadi, Sharky, Shaunr07, shivaprasad, shulav512447, Shuuriye, sidtune, sigitsolo, Simons Svirskis, Siwela Trading, sjmalik40, smjahangir, snipeer, softsky, somewhat, somin, sparty007, sri4you, sss343344, steeldrum, Stéphane Reynaud, Steve64, sukyx, SUMITO, sutheekarn, Syaeful Tri, Sydney2000, ta srenevasan, Tajay Authors, Tan Geok Lin, Tasawar51214, taudin, tech1979, Teck Fui Chin, Thamsanqa, thanet, Thanush Kanagarasa, theCuchuoi, ThreeLions, thush6677, todd, toklapin, toklaping, Tony Levanic, Trader_Z, TradeXtra, tradingralf, traoreoli, Tristan@900, tskabilan, tuiwin8, umaporn253299, universe4x, valleyboys242, Vanyo Nikolov, Veracity, vhagwie, Vitaro, vsd1968, Waleed28, walidshahbudin, Wayne Dube, widadi, Wiljou, win520923, Wiseman09, xiangjn99, Xman, XOLANI, xplorfx, yaojintong, yiwanfuweng, Yolanda Taylor, Yugoez, zeevlas43, Zhero, Zoltan0013, Zomby2584, Олег66, سلما احمد, علی فهیم پور, นาย นิติกร พิฑูรมานิต, สุรศักดิ์ ผังดี, 富樫 裕資

NOTE: Only open-source Forex robots allowed to upload. Hacked or illegal versions of copyrighted Forex robots are highly prohibited on MT4talk.com. If you upload any illegal version of any copyrighted Forex robot, your forum account will be banned. No exceptions.

MT4talk is a User Generated Content website. All content uploaded to MT4talk by our users (MT4talk forum members) is User Generated Content. Please note that MT4talk doesn't sell Forex robots and does not provide support for the uploaded Forex robots. MT4talk only sells PRO membership. PRO membership is unlimited download access in every forum topic and forum posts.


CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members or the MT4talk EA Tester Team about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.


Affiliates Disclaimer - The site may contain links to affiliate websites, and we receive an affiliate commission for any sign up that trade by you on the affiliate website using such links. Our affiliate partner includes the following: FXopen, FBS, LQDFX, MyForexVPS.

Copyright MT4talk.com Forum Rules - Privacy Policy.