Kolier.Li logo
  • Home
  • Article
  • Example
  • Indicator
  • Trading System
  • Project
  • Glossary
  • MT4 Coding Service
  • NinjaTrader Coding Service
Home ยป Example

How to Make EA Auto Fits 4, 5, 6 and Any Digits Form Platforms, Unit in Pips.

Wed, 07/21/2010 - 10:35 | kolier 0 comments
Usually the old EA only fits one digits form platform, or use Unit in Points when set to 10 to represent 10 pips in 4 Digits, set to 100 to represent 10 pips in 5 Digits, etc.

This is a simple algorithm I'm using in all my EA for a long time and proof working, so they are all setting in pips for this related topic, and automatic changed into the platform specific Points.
The reason for creating this is because I have seen there are many not wise implementation.

Function pips2Points()
//+------------------------------------------------------------------+
//| pips2Points() @http://kolier.li                                  |
//+------------------------------------------------------------------+
double pips2Points(double pips)
  {
   double points;
   if(Close[0]<10) {
      points = pips*MathPow(10,Digits-4);
   }
   else if(Close[0]>10) {
      points = pips*MathPow(10,Digits-2); 
   }
  
   return(points);
  }

Use Case

User Input Parameters
extern double TakeProfit = 10; // In Pips. Take Profit, Change to 0 if you don't want to use.
extern double StopLoss = 10; // In Pips. Stop Loss, Change to 0 if you don't want to use.
Implementation
tp = pips2Points(TakeProfit)*Point;
sl = pips2Points(StopLoss)*Point;
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-sl, Ask+tp);
  • Projects
  • Examples
  • Indicators
  • Trading Systems
  • Convertion
  • MT4
  • MT4
  • Snippet
  • Programming

Search

Hot Forex Offers

Get Cash Back on All your Forex Trades, Win or Lose
Free Auto Trade Signals
Premium Trading Signals

User login

What is OpenID?
  • Sign in with Twitter
  • Log in using OpenID
  • Cancel OpenID login
Facebook Connect
Sign in using Facebook
  • Create new account
  • Request new password

Example Category

  • Event Leading
  • Maths Theory
  • Indicator Use Case
  • Trading System
    • Entry Logic
    • Exit Logic
    • Money Management
  • Programming
    • Algorithm
    • Function
    • Snippet
  • Software
    • Trading Plaform
      • MT4
  • ABOUT
  • PRIVACY POLICY
  • Risk Disclaimer
  • CONTACT

© 2012 Kolier.Li All Right Reserved.