Webinars

Free Registeration for:

Monday session
Wednesday session
Thursday session

ForeXecutor


Free ForeXecutor Demo Account

Exploring a simple script** Print E-mail
I decided that I want to talk about something that I have been working on for the last year, and after attending a seminar over the weekend, I decided to just do it. Someone said something to me that really stuck. I am going to paraphrase it, but here it is. You can give people whatever they want and very few of them are going to use it or be satisfied with it.


So in that spirit, I am going to share a script that I worked on for better part of a year. It isn’t a wildly profitable script but it has a lot of elements in it that can be applied to many other scripts and will teach you a lot about scripting.

I’ll post it here in its entirety, and then over the next few days I’ll break down each part so you can see what I did. I had some help with the script, and thank those that helped.

The first thing I’ll talk about is the code in Red. I created this so that the variables in the list could be switched out and tested. In this script I tested a cross of two EMA’s for an open and a close condition. However if I wanted to test how a different MA cross would work I could simply switch out the EMA’s and WMA’s for a different MA

This allows me to make a lot of changes on the fly without screwing with the heart of the script.

Here is the script with original EMA’s and WMA’s**
forex chart

Here is a chart with a HMA substituted for the WMA’s.**
forex chart

//Adjust these Variables as needed

BuyTakeProfit Point(100)

SellTakeProfit Point(100)

BuyStopLoss Point(100)

SellStopLoss Point(100)

Local ECA = EMA[0](Close, 1)

Local ECB = WMA[0](Close, 3)

Local XCA = EMA[0](Close, 10)

Local XCB = WMA[0](Close, 34)

Normal 0 false false false EN-US X-NONE X-NONE

global int ii

global int hh

global lastBreakPrice

global lastBreakPriceBS //the lastBreakPrice with buy/sell action

global int buysellzone //-1 sell zone; 1 buy zone; replace getValue("4 hr. 40 day", issellposition)

//approximate 4 hour BB breakout

if (High[0]>= BLG_U[0](Close, 80, 2)) then

buysellzone=-1

lastBreakPrice=high[1]

endif

if (Low[0]<= BLG_L[0](Close, 80, 2)) then

buysellzone=1

lastBreakPrice=low[1]

endif

//crossover

if buysellzone=-1 and lastBreakPricelastBreakPriceBS

and CrossDown(ECA , ECB) and

ECA < BLG_U[0](Close, 80, 2)) then

AddSellEntry

lastBreakPriceBS=lastBreakPrice

ii=ii+1

ENDIF

if buysellzone=1 and lastBreakPricelastBreakPriceBS

and CrossUp(ECA , ECB) and

ECA > BLG_L[0](Close, 80, 2)) then

AddBuyEntry

lastBreakPriceBS=lastBreakPrice

hh=hh+1

ENDIF

if isbuyposition then

addbuyexit BElOW = lastBreakPriceBS - Point(0))

endif

if issellposition then

addsellexit OVER = lastBreakPriceBS+ Point(0))

endif

if isbuyposition and

CrossDown( XCA, XCB) then

addbuyexit

endif

if issellposition and

CrossUp( XCA, XCB) then

addsellexit

endif

Comments
Add New Search
+/-
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
 
Please input the anti-spam code that you can read in the image.
Kimball  - File   |53
Anyone that wants this, give Jake a call and he will just send you the file. For
some reason the CSS in our site is making the text not match the original.
Cal   |55
I'm getting an error messge. It says:

Ln, 17, Col. 7:C0006: Normal:
statement not supported.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."