You didn't post a topic yet. Let us show you how to make your first topic and upload your favorite forex robot. Guide me

Skip to forum content

Quick Login / Register with Facebook Account!

Login with Facebook

Login with Username and Password!

     Username:       Password:  Login

Register  |  Forgot Password?

 

The latest topics with attached files (Forex robots, Forex Indicators, etc..)

Forums in this category with details of Replies, Views, last post

Richfx Robot

by trichisami

best robot 2018

by jejoy

EA

by Alemkhil

Hide

Highest Forex Leverage 1:3000!

Try your Forex Robot with the highest leverage 1:3000! All Forex robot strategies allowed! Scalping, hedging, martingale, etc...

If you make a deposit as small as $10 in your Forex account, you can enter trades with $30,000 buying power. If you deposit $200 you can enter trades with $600,000 buying power.


Pages 1

You must login or register to post a reply

RSS

Posts: 2
Please rate this topic
Current rating: 0
Votes: 0

Embed topic to your site

PSAR

Topic: PSAR

//+------------------------------------------------------------------+
//|                                                 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<MinBars ){
      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(PSARPrice<StopLossPrice && PSARPrice>Close[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);
   }
  }
//+------------------------------------------------------------------+

Post's attachments

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

Share

Thanked for the post: jozmik

Re: PSAR

li will check this, thank you very much, i have some eas, i will post here, thank you for all information, see you later, thank you very much

Share

Posts: 2

Pages 1

You must login or register to post a reply

Last Posts

  • 13/12: best robot 2018
  • 13/12: Profit Master EA
  • 13/12: Richfx Robot
  • 13/12: cyberia trader
  • 13/12: One day Profit.
  • 13/12: Forexhackers-EA_V2
  • 13/12: EA Asia Scalper
  • 13/12: EA Tahan Banting v3.2
  • 13/12: HMA Expert Advisor for MetaTrader 4
  • 12/12: H1 Trend EA
  • 12/12: EURUSD EA
  • 12/12: Bitmex robot
  • 12/12: assistance from my broker
  • 12/12: EA trading ZigZag indicator when pointing outside the Bollinger Bands.
  • 12/12: EA
  • 12/12: Moving GRID EA
  • 12/12: Ronix v4 EA
  • 10/12: To accomplish
  • 10/12: Facing losses
  • 10/12: PingTouGe,a fantastic EA
  • 10/12: XtreamForex Company News
  • 10/12: Due to the changes
  • 09/12: Awesome EA, with Cent account should be just fine
  • 09/12: EA Generic A-TLP v.12.38
  • 09/12: Help with EA inputs
  • 09/12: Automated trading system
  • 09/12: 500% profit per week! Forex Robot!
  • 09/12: abundant reasons
  • 08/12: trading at the right time
  • 08/12: Indrafxscalping v8
  • Online Users & Stats

    • Total number of registered users: 25,948
    • Newest registered user: lbrt.cstr
    • Total number of topics: 11,445
    • Total number of posts: 37,479

    Online users: 2,187 guests, 294 Members:

    627040574, 777legrand, 845607783, AbbyR, adam12za, AdamVPS, adil_07fb, admin, afandee90, afc123, Ahmet Yasin Gülbeyen, ahouanseromeo10, ajdtradnig, Albertos, alecke34, Alexander Lamount Knowles, alldren, ameyakambleameya, Amit Singh, andydrae67, aprice220466, arafat.wed19, Arjune Krishna, Art Dejavu, arun26180, askforonecoin, atengatara, atizaque, Avesani Maurizio, axel7969, Baburali95, ball2goal, basser-26, Behi Juvencio, Belkacem Lounis, BENEX, bestkid321, betuboxem, billapk, biztet, bluezjone, BMWKOLA, boldoo1231, boobo, booysen.s92, Brahim Hadef, BrandonBoyd, Brayan, cargelli2015, carldias2020, catacre, chenglijin, chenyayuzx, Choosak Lertvichamai, Christian Kopp, Chuks Abram, coachklso, coffeealone1609, corrabot, cr7rn10, Cretu Vasile, cruelzhang, csk0077, Damien Cherry, dancard84, danieldake4, danyshiandez, dare79, Darshana Samaraweera, davbene74, Deni, didinusss, Diederich Müller, dmlye2004, dmp.forex, Don Jay, donaldoruma489, Donnie Drajat, Donovan Sissing, doolph, dow017, dvorynen, Eakapun, eaze1six, ecker8415, Eduardo Montanha, Enroute, Eric Cheung, eugenio.nabor, experteas2014, faa1541, Fadzil Yusof, farmabioq, fbfx12, flsekme, Forex Stock Trading, forex0801, forexprofit2018, franck0naka, freewilly, fxvnpro, Gaspard, geo.hafez, George Kourogiorgas, ggarza, Gid Omo, gungink, guojr, gys, hanhtinhxanhdo, hemanth.mp361, hendrikwong, Hery Setiawan, horacewh, Horry Yue, Hoven AL, hussain.tradeexpress, ian.kungu, ich61, igniz, imam.gozali329, imsamphors, Inconito75, inversionesromaguerrero, ishop888, jailson925, Jarocho, Javier Sanchez Burrix, jaysonajax, Jean Costa, jejoy, Jesus Flores, jhonatan921, jjeg1979, Jlccorp, jmvr30i, joaofloresneto, Joe0013, John Maker, joinbehar, José Luis Pérez, jp_satriane, juanjoserra, juanvincent, judeekatherinexx, Junior Vix, Justonetrading, Kabelo Collen Molokwe, Kafid Bram, kamalkumar_j, kangmasrowi, Ken Sato, killamah, kill_li, Kojo Bame, kumarpetroleum81, Layers, lbrt.cstr, Lerka, LilKeo Seony, Liviu Torac, llight08, Lo Zi Quan, longpiahfx, Lucas Alonso, machemitoccafa, machs_nochmal, madanluhar, madebybel, magmonmonm, mandysoy, Marais, marbre, Marc Thériault, MarianNick123, Mario Alz, mariotboy007, Martin Kirschner, maxdavis2999, mayiselak, meiyan, meleriste, miguel061195, mikeb4, Mohd Ismail, Montipora, mountain8283, mrmaggi007, Muhammad Asghar, murugesan, Myanmar River, myd1688, naeemulhaque, nakatama1, nandvoleti, nasirsmart61, nemaste, netprofit, Nico Bilio, noeltg, nofear89, Nuno Amorim, Okan Polat, omalix, omidazizi1366, orlandog, ozzyasky, pablomercosul, pachu, paroucia, paulmb61, pellingrini45, peter2017, Peyman Samavatian, pholza55, phuonglan19, pregem, prokonal, ptctodo, pWs224, qas383, Qym Kimdan Chirchir, rad1958, rafik_fex, Re Kristin, Renato Vs Elizaine Ribeiro, Ricardo09, ripon.allreg, RMC, ron2009, Roson Chea, rubenet33, ryan.colitz51, said.qurbanov4, salifmhd1, Salomo Christoffel, Sarawut Seeladha, Sarun Numkanisorn, savychostap177, shahbaz.star333, shaundavis111, shtefan, Silvio Alves, sivahemantha, Siwakhile Mpandza, spica.razif, sprizzon, steverson, subbarao59, suyadi, Szwaj Kleofas, Taposki99, tareqosman, Teeman, tekinyer, Thim Bérénice, Titus Judah, Traderfox2610, trading1735, tradingralf, trichisami, truongkhanhduy, tuncay, uzobusy11, Vadim007, vadvid, vallo444, Victoriano, viet.hoangq, vodafone2066, wahyucheat, Wajid Hussain, Waliu Ajose, Welsige, why, willybids, wondermtc, xg5463, XSniper Call, yahavuzan, Yai Megaforce, Yannick Bonyoma, yassineait110, yildiz, zafarjoia, zeefx, zininou, zrodox9, Анатолий Науменко, אירועי תרבות, ودمعي دوم بعيوني, สมบัติ แสนบุตร, 悠宇丞小瀧, 振豪

     


    NOTE: 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.

     

    IMPORTANT: MT4talk.com is a public Forex forum, where forum members can upload open source Forex robots to share with other members. MT4talk.com forum does not sell or rent Forex robots, and does not provide guarantee or support for the uploaded Forex robots! If you have any question about any Forex robot, please open a forum topic! If you have a question about your forum account, contact: mt4talk@gmail.com

    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 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.


    Copyright MT4talk.com Forum Rules - Privacy Policy.