Mtf Moving Average Strategie
MTF Moving Average MT4 Indikator MTF MA zeichnet jegliche Art von gleitenden Durchschnitten auf einem beliebigen Zeitrahmen auf. Sie können täglich bewegte Durchschnitte auf 30m Chart verfolgen. Dies ermöglicht es Ihnen, alles auf einem Diagramm zu verfolgen. Sie haben mehr Platz für andere Währungspaare. Umzugsdurchschnitte werden im Devisenhandel weit verbreitet. Sie werden verwendet, um die Trendrichtung zu identifizieren und Stützresistenzzonen zu lokalisieren. MTF Moving Average MT4 Indikator 8211 basiert auf gleitenden Durchschnitten, können Sie es für Stop-Loss oder regelmäßigen Handel verwenden. Preis oben Indikator 8211 Trend, unten unten Trend. Tf 8211 Zeitrahmen Quelle Periode 8211 die Periode des Gleitverfahrens 8211 das Verfahren der Mittelung der Datensatz Verschiebung 8211 Verschiebung jeweils MTF SuperTrend Trading System - Forex Strategien - Forex Resources - Forex Trading-freie Forex Trading Signale und FX Forecast 444MTF SuperTrend Trading System MTF Supertrend-Indikator Combo MTF Supertrend Trading System ist ein reines Trend folgendes System, seine eine Combo-Strategie auf Supertrend-Indikator und exponentielle gleitenden Durchschnitt 5 Periode basiert. Diese Vorlage ist für 15 Minuten Zeitrahmen eingestellt. Währungspaare: Majors, EURUSD, GBPUSD, AUDUSD, NZDUSD, USDCAD, USDJPY, GBPJPY. Metatrader-Indikatoren Einstellung: Supertrend Clear (wird für MTF Supertrend benötigt) MTF Supertrend (TF 60, CCI 60, ATR -1) UP Down Indikator (HL 4 Dies ist Preis-Aktions-Indikator und Repaint) Exponentiell gleitender Durchschnitt 5 Periode (Median Preis). Regeln für MTF Supertrend Trading System SuperTrend MTF in Sub-Fenster Zeile Farbe grün SuperTrend klar auf der Karte Linie Farbe grün nach oben Indikator Punkt Farbe grün Wenn diese Bedingungen sind einverstanden lange Einstiegsposition, wenn der Preis auf 5EMA zurückverfolgt. SuperTrend MTF in Unterfenster Linie Farbe lila SuperTrend klar auf der Karte Linie Farbe rot nach oben Indikator Punkt Farbe rot Wenn diese Bedingungen vereinbaren kurze Einstiegsposition, wenn der Preis auf 5EMA zurückverfolgt. Die gleichen Bedingungen, aber verwenden Sie Supertrend auf Diagramm, UP down und 5 Ema. Anfänger-Stop-Loss auf dem vorherigen Highlow-Swing. Profit Target 20-30 Pips oder Gewinn auf die Pivot-Punkte Ebene. Wie verwenden Moving Averages in Forex Trading Einfache, aber effektive Multi Time Frames Strategie. Die Moving Averages (MAs) im Forex-Handel ist die einfachste und dennoch effektive Handelsstrategie. Und wenn Sie es auf Multi Time Frame (MTF) verwenden, haben Sie immer die höchste Wahrscheinlichkeit Setup. Aber was ist ein Moving Average Der Moving Average ist ein Trendpunkt Indikator. Weil auf den vergangenen Preisen basiert Angesichts einer gewissen Zeit für die MA, bedeutet, dass nach jedem Schließen, die MA Position und Wert, wird sich ändern. Dies ist der Grund, warum die MA als ein Nachlaufindikator (neu lackiert) betrachtet wird. Simple Moving Average (SMA) vs. Exponential Moving Average (EMA) Es gibt viele Moving Averages Typen, aber diese beiden sind die beliebtesten: 1. The Simple Moving Average (SMA). Stellen den mathematischen Durchschnittspreis einer bestimmten historischen Zeitspanne dar. In der Regel wird dies auf die 8220close8221 Preise angewendet, aber es gibt viele andere Optionen (offen, hoch, niedrig, etc.). 2. Die Exponential Moving Average (EMA) Formel reduzieren ein bisschen die Verzögerung, indem sie mehr Gewicht auf die jüngsten Preise. Besonders wenn Sie einen großen Wert für Ihre EMA verwenden. Ie 200 EMA auf Täglich 8211 Die letzten Tagespreise geben mehr Gewicht in der Moving Average Formel, als die ältesten Preise. Verschieben von Mittelwerten als Zeigeindikator (Uhrzeiger) Da die Preise auf einem Diagramm von links nach rechts gemalt sind, haben wir grundsätzlich 2 mögliche Richtungen und 1 für den Bereichsmarkt: 1. 82201-2 o8217clock8221 bullish trend 2. 82203 o8217clock8221 range oder A flat MA 3. 82204-5 o8217clock8221 bärischer Trend Exponential Moving Average (EMA) auf dem Multi Time Frame Handel (MTF) Im Handel zählen wir mit den höchsten Wahrscheinlichkeitseinstellungen. Niemand kann den nächsten Preiswert vorherzusagen. Aber wenn du die Höhere Zeitrahmen (HTF) Richtung betrachten und deinen Eintrag auf den unteren Zeitrahmen (LTF) in die gleiche Richtung stellen wirst, hast du mehr mathematische Chancen, richtig zu sein. Warum denn wie jeder nacheilende Indikator, der MA, wird weniger auf dem HTF verzichten. Wie man Trades mit dem EMA gut platziert, hängt davon ab, welche Art von Handel Sie sind. Die meisten der Händler ziehen es vor, die Breakouts (BO) zu handeln, also legen sie BuySell Stop Pending Orders ein. Während andere auf den SupportResistance (SR) retest warten, also setzen sie Limit Pending Orders. Durch die Platzierung von Trades wie folgt ist der Stop Loss (SL) in der Regel auf der nächsten SR-Ebene. Oder gerade unten Unterstützung für lange Trades (oder über Resistance für kurze Trades). Ich persönlich benutze die Fibonacci Retracement 50 und und 61.8 Levels, um meine Pending Orders in die Richtung der BO zu setzen. Und ich benutze als Stop Loss (SL), die 100 Level. Natürlich, durch Messung der Schaukel, dass die EMA8217s BO bestätigt. Für den Take Profit Level (TP) verwenden die meisten Trader das entgegengesetzte Signal am Eingang TF (PA, das die 200 EMA überquert) oder den nächsten SR Level. Aber das macht dir ein min 1: 3 als R: R Ratio. Mit dem HTF8217s 200 EMA Crosingretest könnte der Job machen. Ich benutze die Fibonacci Retracement auf der letzten Zähler Trend hinzugefügt. So kann mein TP 127,4, 161,8 und und 261,8 sein, auf der Suche nach einem Minimum von 1: 3 als R: R-Verhältnis (RiskReward Ratio). Wenn mein TP nicht mindestens 3xSL ist, senke ich meinen Eintrag TF auf H1 und treibe dort die nächste Swing. Auf diese Weise werde ich einen glatteren Eintrag haben, mit einem kleineren SL, während ich meine HTF8217s TP behalte. Also mein kleiner TF-Eintrag wird ein Versuch sein. Und ich kann es mir leisten, viele Einträge zu verlieren, um die H48217s SL auszugleichen. Das gibt mir später ein R: R in der Regel mehr als 1: 5 oder 1: 8 oder höher. Wenn Sie ein Position Trader sind, können Sie auf diese Weise verwenden, die HTF8217s Zähler Trend Fibonacci Retracement. Aber für diese Idee empfehle ich Ihnen, Ihre anfängliche SL mindestens einmal in den Gewinn zu verlagern (um Ihren Gewinn zu sperren). Und dann können Sie Ihre rentable Position laufen lassen, bis das HTF8217s TP ausgelöst wird. Wie man falsche Breakouts vermeidet Jedes Mal, wenn ein Werkzeug gebrochen ist, muss auch das erste Highlow gebrochen werden, um den Breakout (BO) zu bestätigen. Ansonsten müssen wir bedenken, dass die erste BO a 8220false BO8221 bei der MA8217s erneut zu testen. Und dieser Highlow wird später ein Ross Hook (Rh) oder Fractal. Was auf diesen Theorien basiert, muss auch gebrochen werden, um die Veränderung des Trends zu berücksichtigen. Auf HTFs die MAs wiederholen mit einem falschen BO, won8217t in der Regel ändern die MA zeigen. Bei LTFs könnte der MA8217s BO zunächst durch eine neue Highlow bestätigt werden, die später ungültig gemacht werden könnte. Und danach könnte die Preisaktion (PA) die HTF8217s Richtung fortsetzen. Auch wenn der LTF8217s BO zunächst bestätigt wird. Fallstudien. Einrichtungsbeispiele für EMA auf MTF. Nur um diese einfache, aber effektive Handelsstrategie zu verstehen, die auf den exponentiellen Moving Averages auf Multi Time Frame basiert, gebe ich Ihnen einige Setups (Szenarien): Das ist das AUDJPY Paar, auf der Weekly, Daily und den H4 Charts. Basierend auf der 200 EMA zeigt bullish, auf allen 3 Charts, nehmen wir lange Positionen, nur. 8211 wöchentlich lang 8211 Täglich lang (sogar bei 200 EMA retest, die EMA war immer noch bullisch) 8211 H4 lang (sogar bei 200 EMA retest, mit einem falschen Breakout, die EMA war immer noch bullish) Dies ist das AUDUSD Paar, auf der Wöchentlich, Täglich und die H4 Charts. Auf der wöchentlichen Tabelle haben wir die Preisaktion (PA), unter der 200 EMA, so dass der langfristige Trend noch bärisch ist. Aber auf den H4 und Daily Charts ist die PA über der 200 EMA. So können wir entweder auf die H4 warten, denn die PA geht unter die 200 EMA (die wöchentliche Tendenz) und den Handel kurz. In diesem Fall, nach der Kreuzung, müssen die 200 EMA uns bärisch zeigen, auf der H4 auch. Oder wir können auf das wöchentliche Diagramm warten, um die gleiche lange Richtung zu bestätigen, später. Wir gingen über die 200 EMA auf H4, dann auf die Daily. So können wir annehmen, die PA wird über die 200 EMA auf der wöchentlichen auch gehen. 8211 Wöchentlich kurz 8211 Täglich lang (sogar bei 200 EMA-Test, die EMA war immer noch bullisch) 8211 H4 lang Das ist das EURUSD-Paar, auf der wöchentlichen, täglichen und die H4-Charts. Basierend auf der 200 EMA zeigt bullish, auf allen 3 Charts, nehmen wir lange Positionen, nur. Wenn auf der H4 die PA unter die 200 EMA gehen wird, werden wir aufhören, dieses Paar zu handeln. Wenn später die PA unter die 200 EMA auf der Täglich gehen wird, warten wir auch auf die H4 für die PA, um unter 200 EMA zu laufen, um auch kurze Positionen zu nehmen und mindestens eine wöchentlich 200 EMA zu erwarten Wiederholen (was wir auf der H4 sehen, sollte auf der Täglicher gesehen werden, später und danach auch auf der wöchentlichen). 8211 wöchentlich lang 8211 Täglich lang (nach einer flachen 200 EMA, die PA brach es und schuf eine neue hohe Bucking der wöchentlichen Trend) 8211 H4 lang (sogar bei 200 EMA retest, mit einem falschen Breakout der Unterstützung, war die EMA noch Zeigte bullish) Die Moving Averages, die auf Multi Time Frame handeln, kann eine sehr profitable Strategie sein, denn Sie werden immer die höchsten Wahrscheinlichkeitseinstellungen in Richtung der Higher Time Frames handeln. Durch die Verwendung mit einem guten Money Management System und einem R: R Verhältnis von mindestens 1: 3 solltest du immer auf der gewinnbringenden Seite sein. Und natürlich, als Haftungsausschluss, empfehle ich Ihnen, diese Strategie auf einem DEMO-Konto zu testen, für einige Monate in einer Reihe, nur um zu sehen, ob dies für Sie arbeitet. Allerdings, wenn Sie später entscheiden, um diese Idee auf Ihrem echten Geldkonto zu verwenden, sollten Sie verstehen, dass alle das Risiko beteiligt ist, wird es Ihnen gehören. Hope this helps. The Code unten zeigt, wie ich derzeit generieren einen gleitenden Durchschnitt für den Einsatz in einer Strategie. Allerdings ist dieser gleitende Durchschnitt auf den Strategiezeitrahmen zurückgesetzt. Was ich tun möchte, ist, diesen gleitenden Durchschnitt zu ändern, um seinen eigenen Zeitrahmen separat (größer) von dem zu haben, der für den Rest der Strategie verwendet wird. Ich habe mit verschiedenen Ideen geschehen, um dies zu tun, aber nichts funktioniert, würde ich sehr schätzen, wenn mir jemand zeigen könnte, wie man das mit dem Beispielcode unten macht: nb bitte auch alle Änderungen, die für die ersten () Berechnungen benötigt werden. Strategie. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) Strategie. parameter: addStringAlternative (quotTrendMAMethodquot, "Quert", "Quint", "Notiz", "Notiz", "Notiz", "Notiz", "Notiz", "Notiz", "Quin - Parameter: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotZeroLagEMAquot, Aquot, quote, quote, quote, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, quadratisch, addStringAlternative (quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotILRSquot, quotquot, Quartalquot. dieArbeitsphase, Quelltext, Quittierung, Quelltext, Quittung, Quelltext, Quittierung, Quelltext, Quittierung, Quelltext, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, "TrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters: addString (quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters: addStringAlternative (quotTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters: addStringAlternative (quotTypequot, quotHIGHquot, quotquot, quotHquot ) Strategie. parameters: addStringAlternative (quotTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters: addStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) Strategie. parameters: addStringAlternative (quotTypequot , QuotTYPICALquot, quotquot, quotTquot) Strategie. parameters: addStringAlternative (quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters: addGroup (quotPricequot) strategy. parameters: addString (quotPTquot, quotPrice Typquot, quotquot, quotBidquot) Strategie. parameter: addStringAlternative ( QuotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters: addStringAlternative (quotPTquot, quotAskquot, quotquot, quotAskquot) strategy. parameters: addGroup (quotTimeFramequot) strategy. parameters: addString (quotTFquot, quotTime Framequot, quotquot, quotm5quot) Strategie. parameters: setFlag (QuotTFquot, core. FLAGPERIODS) Ende lokaler gSource - Streams lokaler TrendMAMethod lokaler TrendMAPeriod lokaler TrendMA lokaler P1 TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstanz. parameters. Type gSource ExtSubscribe (1, nil, instance. parameters. TF, instance. parameters. Type quotBidquot, quotbarquot) if Type1 quotOquot dann P1 gSource. open elseif Typ1 quotHquot dann P1 gSource. high elseif Typ1 quotLquot dann P1 gSource. low elseif Typ1 quotMquot dann P1 gSource. median elseif Typ1 quotTquot dann P1 gSource. typical elseif Typ1 QuotWquot dann P1 gSource. gewichtet sonst P1 gSource. close Ende TrendMA core. indicators: create (quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) - und bekomme den ältesten Index der Bar, an der wir zuerst arbeiten können math. max (TrendMA. DATA: erste (). Etc.) Endfunktion ExtUpdate (id, Quelle, Periode) - Wenn wir genügend Stäbe im Verlauf haben, um zu arbeiten, wenn Periode gt zuerst 1 dann Jetzt kann ich die MA verwenden Abonnieren Sie einen anderen Zeitrahmen Code: Wählen Sie alle gBTFSource ExtSubscribe (BTFID, Nil, instance. parameters. BTF, instance. parameters. Type quotBidquot, quotbarquot) und verwenden Sie es in der Indikator anstelle von gSource Code: Wählen Sie alle P1 gBTFSource. open. Um den Index des ersten Wertes zu erhalten, musst du den Index des Hauptzeitrahmens auf den Index des größeren Zeitrahmens wie folgt setzen: Code: Alles auswählen TrendMA. DATA:First (). Lokal btfPeriod core. findDate (gBTFSource, gSource: date (Periode), true) Wenn btfPeriod gt erste 1 dann Ive diese Fixes hier enthalten: Code: Alles auswählen Init () strategy. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot ) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot , QuotLWMAquot, quotquot, quotLWMAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotDEMAquot , Quot quotAlternative (quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) Strategie. parameters : addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotIE2quot, quotquot , Quotie2rot) Strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters: addInteger (quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters: addString (QuotTypquot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters: addStringAlternative (quotTypequot, quotOPENquot, quotquot, quotOquot) Strategie. parameters: addStringAlternative (quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters: addStringAlternative (quotTypequot, quotLOWquot, quotquot, QuotStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters: addStringAlternative (quotTypequot, quotTYPICALquot, quotquot, quotTquot) Strategie. parameters: addStringAlternative ( QuotTypquot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters: addGroup (quotPricequot) strategy. parameters: addString (quotPTquot, quotPrice Typquot, quotquot, quotBidquot) strategy. parameters: addStringAlternative (quotPTquot, quotBidquot, quotquot, quotBidquot) Strategie. parameter: addStringAlternative (QuotTTotto, quotAququot, quotAskquot, quotquot, quotAskquot) Strategie. parameters: addGroup (quotTimeFramequot) Strategie. parameter: addString (quotTFquot, quotTime Framequot, quotquot, quotm5quot) Strategie. parameters: setFlag (quotTFquot, core. FLAGPERIODS) Strategie. parameter: addString ( "BTFquot, quotBigger Time Framequot, quotquot, quotH1quot) Strategie. parameters: setFlag (quotBTFquot, core. FLAGPERIODS) Ende lokaler gSource - Streams lokaler gBTFSource - Streams lokaler TrendMAMethod lokaler TrendMAPeriod lokaler TrendMA lokaler P1 lokaler MAINTFID 1 lokaler BTFID 2 TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstanz. parameters. Type gSource ExtSubscribe (MAINTFID, nil, instance. parameters. TF, instance. parameters. Type quotBidquot, quotbarquot) gBTFSource ExtSubscribe (BTFID, nil, instance. parameters. BTF, instance. parameters. Type quotBidquot, quotbarquot) if Type1 quotOquot dann P1 gBTFSource. open elseif Typ1 quotHquot dann P1 gBTFSource. high elseif Typ1 quotLquot dann P1 gBTFSource. low elseif Typ1 quotMquot dann P1 gBTFSource. median elseif Typ1 quotTquot dann P1 gBTFSource. typical elseif Typ1 quotWquot dann P1 gBTFSource. gewichtet sonst P1 gBTFSource. close Ende TrendMA core. indicators: create (quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) - und bekomme den ältesten Index der Bar, an der wir arbeiten können. TrendMA. DATA:first () end Funktion ExtUpdate (id, source, period) if id MAINTFID und gBTFSource: size () gt 0 dann TrendMA: update (core. UpdateLast) lokal btfPeriod core. findDate (gBTFSource, gSource: date (period), true) - wenn wir Haben genug Stäbe in der Geschichte zu arbeiten, wenn btfPeriod gt erste 1 dann - Jetzt kann ich das MA End End Ende Es gibt nur drei Sportarten: Stierkampf, Motorsport und Bergsteigen alle anderen sind nur Spiele. (C) Ernest Hemingway Hallo Victor. Tereschenko, Vielen Dank Victor das war eine tolle Hilfe, aber ich bin immer noch wie folgt fest: - Der komplette Code ist unten, ich habe einige Signal (Test Punkte), um den Fortschritt durch die Logik zu überwachen Und stellte fest, dass der Code auf der Strecke versagte: 284 Wenn btfPeriod gt zuerst 1 dann die Werte wie folgt ausfallen: - EURUSD LONNY02SIGNAL, EURUSD, cci20, m1, Beide 2 TP0 - START: btfPeriod (-1) gt zuerst (199) 1 08252011 10:08:00 1.44073 Das Problem ist offensichtlich btfPeriod bei -1 Angabe Ive getan ein Blooper irgendwo am ehesten, sind Sie in der Lage, das Problem zu sehen. Vielen Dank Peter Newton Code: Alles auswählen - Intoduce die Strategie auf die Host-Anwendung (zB Marketscope). - Die Funktion wird einmal aufgerufen, wenn die Host-Applikation zunächst die Strategie lädt. Funktion Init () Strategie: Name (quotLonNY02Signalquot) Strategie: Beschreibung (quotLonNY02 Signaling Strategyquot) - Schnelle und langsame gleitende Mittelwerte Parameter. parameters: addGroup (quotMain Controlsquot) strategy. parameters: addString (quotTFquot, quotStrategy Time Framequot, quotquot, quotm5quot ) Strategie. parameters: setFlag (quotTFquot, core. FLAGPERIODS) Strategie. parameters: addString (quotALLOWEDSIDEquot, quotAllowed sidequot, quotAllowed Seite für Handel oder Signalisierung, kann verkaufen, kaufen oder beides, quotBothquot) Strategie. parameters: addStringAlternative (quotALLOWEDSIDEquot, quotBothquot , Quotquot, quotBothquot) Strategie. parameters: addStringAlternative (quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) Strategie. parameters: addStringAlternative (quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) Strategie. parameters: addBoolean (quotSquot, quotSetup Alertquot, quotquot, true) Strategie. Parameter: addBoolean (quotTquot, quotTrigger Alertquot, quotquot, true) Strategie. parameters: addBoolean (quotCTquot, quotConfirmed Trigger Alertquot, quotquot, false) Strategie. parameters: addGroup (quotAlertsquot) strategy. parameters: addBoolean (quotShowAlertquot, quotShowAlertquot, quotquot, true ) Strategie. Parameter: addBoolean (quotPlaySoundquot, quotPlay Soundquot, quotquot, true) Strategie. parameters: addFile (quotSoundFilequot, quotSound Filequot, quotquot, quotquot) Strategie. parameters: setFlag (quotSoundFilequot, core. FLAGSOUND) Strategie. parameters: addBoolean (quotRecurrentSoundquot , QuotRecurrent Soundquot, quotquot, true) Strategie. parameters: addBoolean (quotSendEmailquot, quotSend Emailquot, quotquot, false) Strategie. parameters: addString (quotEmailquot, quotEmailquot, quotquot, quotquot) Strategie. parameters: setFlag (quotEmailquot, core. FLAGEMAIL) Strategie. parameter: addGroup (quotCCI Parameterquot) Strategie. parameter: addInteger (quotCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) Strategie. parameter: addGroup (quotBigger Zeitrahmen MA Parameterquot) Strategie. parameter: addBoolean (quotBTFMAFlagquot, quotBigger Zeitrahmen MA Trend onquot, quotquot, true) strategy. parameters: addString (quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, "TrMAquot, quotquot, quotTriMAquot) Strategie. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) Strategie. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) Strategie. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) Strategie. Parameter: addStringAlternative (quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, Jdmoothquot) Strategie. parameters: addString (quotBTFTypequot, quotBTFPrice Typquot, quotquot, quotCquot) Strategie. parameter: addStringAlternative (quotBTFTypequot, quotOPENquot, quotquot, quotOquot) Strategie. parameters: addStringAlternative (quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) Strategie. parameter: addStringAlternative (QuotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters: addStringAlternative (quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters: addStringAlternative (quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) Strategie. parameters: addStringAlternative (quotBTFTypequot, quotTYPICALquot, quotquot, quotTquot ) Strategie. parameters: addStringAlternative (quotBTFTypequot, quotWEIGHTEDquot, quotquot, quotWquot) Strategie. parameters: addInteger (quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strategy. parameters: addString (quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) Strategie. parameters: setFlag (QuotBTFquot, core. FLAGPERIODS) Strategie. parameters: addGroup (quotStrategy Zeitrahmen MA Parameterquot) Strategie. parameter: addBoolean (quotStrategyMAFlagquot, quotStrategy MA Trend onquot, quotquot, true) strategy. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) Strategie. Parameter: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters: addString (quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters: addStringAlternative (QuotTypequot, quotOPnail, quotquot, quotOquot) Strategie. parameters: addStringAlternative (quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters: addStringAlternative (quotTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters: addStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot ) Strategie. parameters: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters: addStringAlternative (quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters: addStringAlternative (quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters: addInteger (quotTrendMAPeriodquot , QuotTrendMAPeriodquot, quotquot, 200) strategy. parameters: addGroup (quotLevelsquot) strategy. parameters: addInteger (quotOBquot, quotOverbought Levelquot, quotquot, 100) strategy. parameters: addInteger (quotOSquot, quot Oversold Levelquot, quotquot, -100) Strategie. parameter : AddInteger (quotOBCquot, quotOverbought Bestätigung Levelquot, quotquot, 150) strategy. parameters: addInteger (quotOSCquot, quot Oversold Bestätigung Levelquot, quotquot, -150) - Preisabonnement-Parameter (Bid - oder Ask-Preis, Zeitrahmen) Strategie. parameters: addGroup (QuotPricequot) strategy. parameters: addString (quotPTquot, quotPrice Typquot, quotquot, quotBidquot) strategy. parameters: addStringAlternative (quotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters: addStringAlternative (quotPTquot, quotAskquot, quotquot, quotAskquot) - Die globale Variablen lokaler BAR nil - die Preisentwicklung, die wir für die lokale zuerst abonniert haben - der Index der ältesten Periode, in der wir überprüfen können, ob bewegte Durchschnitte überschritten wurden, lokal OB, OS, OBC, OSC lokales CCI lokales Top, unten lokales gBTFSource - Streams lokaler BTFTrendMAMethod lokaler BTFTrendMAPeriod lokaler BTFTrendMA lokaler gSource - Streams lokaler TrendMAMethod lokaler TrendMAPeriod lokaler TrendMA lokaler upArrow nil lokaler downArrow nil lokaler MAINTFID 1 lokaler BTFID 2 lokaler BTFP1 lokaler BTFType lokaler SoundFile nil lokaler RecurrentSound falscher lokaler ALLOWEDSIDE lokales S - Einrichten lokales T - - Lokale CT auslösen - Bestätigen Lokaler Look auslösenBack lokal anzeigen ShowAlert local email local SendEmail local BaseSize-Funktion Vorbereiten () - Vorbereitung aller Daten. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT --downArrow instance:createTextOutput (quotUpquot, quotUpquot, quotWingdings 3quot, 20, core. HCenter, core. VTop, instance. parameters. Bottom, 0) --upArrow instance:createTextOutput (quotDownquot, quotDownquot, quotWingdings 3quot, 20, core. HCenter, core. VBottom, instance. parameters. Top, 0) quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we dont check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(1, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gSource ExtSubscribe(MAINTFID, nil, instance. parameters. TF, instance. parameters. Type quotBidquot, quotbarquot) gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 gSource. open elseif Type quotHquot then P1 gSource. high elseif Type quotLquot then P1 gSource. low elseif Type quotMquot then P1 gSource. median elseif Type quotTquot then P1 gSource. typical elseif Type quotWquot then P1 gSource. weighted else P1 gSource. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first(), BTFTrendMA. DATA:first()) end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id 1 then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if id MAINTFID and gBTFSource:size() gt 0 then TrendMA:update(core. UpdateLast) local btfPeriod core. findDate(gBTFSource, gSource:date(period), true) -- if we have enough bars in the history to work Signal (quotTP0 - START: btfPeriod(quot. tostring(btfPeriod). quot) gt first(quot. tostring(first). quot) 1quot ) if btfPeriod gt first 1 then Signal (quotTP0a - quot. quotbtfPeriod gt first 1quot) -- This bit added for signalling only if BTFMAFlag then if gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end else BTFdir quotOffquot Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if gSource. close91period93 lt TrendMA. DATA91period93 then Signal (quotTP4 - trend Downquot) trendDdir quotDownquot elseif gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySound if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end You have sent id into subscribe: BAR ExtSubscribe(1. ) When update is called with id 1, the period is valid for the BAR source only. gBTFSource has different timeframe and the period with id 1 is not valid to it. You should use converted period (btfPeriod) to access gBTFSourceBTFTrendMA values. Code: Select all gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 instead of Code: Select all gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 first value should be quotsplittedquot into two: Code: Select all first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() . if period gt first then . -- and if btfPeriod gt btfFirst then And Ive made a misprint over here: Code: Select all --local btfPeriod core. findDate(gBTFSource, BAR:date(period), true) local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) Corrected code: Code: Select all -- Intoduce the strategy to the host application (for example, Marketscope). -- The function is called once when the host application initially loads the strategy. function Init() strategy:name(quotLonNY02Signalquot) strategy:description(quotLonNY02 Signalling Strategyquot) -- Fast and slow moving average parameters strategy. parameters:addGroup(quotMain Controlsquot) strategy. parameters:addString(quotTFquot, quotStrategy Time Framequot, quotquot, quotm5quot) strategy. parameters:setFlag(quotTFquot, core. FLAGPERIODS) strategy. parameters:addString(quotALLOWEDSIDEquot, quotAllowed sidequot, quotAllowed side for trading or signaling, can be Sell, Buy or Bothquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotBothquot, quotquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) strategy. parameters:addBoolean(quotSquot, quotSetup Alertquot, quotquot, true) strategy. parameters:addBoolean(quotTquot, quotTrigger Alertquot, quotquot, true) strategy. parameters:addBoolean(quotCTquot, quotConfirmed Trigger Alertquot, quotquot, false) strategy. parameters:addGroup(quotAlertsquot) strategy. parameters:addBoolean(quotShowAlertquot, quotShowAlertquot, quotquot, true) strategy. parameters:addBoolean(quotPlaySoundquot, quotPlay Soundquot, quotquot, true) strategy. parameters:addFile(quotSoundFilequot, quotSound Filequot, quotquot, quotquot) strategy. parameters:setFlag(quotSoundFilequot, core. FLAGSOUND) strategy. parameters:addBoolean(quotRecurrentSoundquot, quotRecurrent Soundquot, quotquot, true) strategy. parameters:addBoolean(quotSendEmailquot, quotSend Emailquot, quotquot, false) strategy. parameters:addString(quotEmailquot, quotEmailquot, quotquot, quotquot) strategy. parameters:setFlag(quotEmailquot, core. FLAGEMAIL) strategy. parameters:addGroup(quotCCI Parameterquot) strategy. parameters:addInteger(quotCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) strategy. parameters:addGroup(quotBigger Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotBTFMAFlagquot, quotBigger Time Frame MA Trend onquot, quotquot, true) strategy. parameters:addString(quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotBTFTypequot, quotBTFPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strategy. parameters:addString(quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) strategy. parameters:setFlag(quotBTFquot, core. FLAGPERIODS) strategy. parameters:addGroup(quotStrategy Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotStrategyMAFlagquot, quotStrategy MA Trend onquot, quotquot, true) strategy. parameters:addString(quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters:addGroup(quotLevelsquot) strategy. parameters:addInteger(quotOBquot, quotOverbought Levelquot, quotquot, 100) strategy. parameters:addInteger(quotOSquot, quot Oversold Levelquot, quotquot, -100) strategy. parameters:addInteger(quotOBCquot, quotOverbought Confirmation Levelquot, quotquot, 150) strategy. parameters:addInteger(quotOSCquot, quot Oversold Confirmation Levelquot, quotquot, -150) -- Price subscription parameters (bid or ask price, time frame) strategy. parameters:addGroup(quotPricequot) strategy. parameters:addString(quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotAskquot, quotquot, quotAskquot) -- The global variables local BAR nil -- the price history we subscribed for local first -- the index of the oldest period where we can check whether moving averages has been crossed local btfFirst local OB, OS, OBC, OSC local CCI local Top, Bottom local gBTFSource -- streams local BTFTrendMAMethod local BTFTrendMAPeriod local BTFTrendMA local TrendMAMethod local TrendMAPeriod local TrendMA local upArrow nil local downArrow nil local STRATTFID 1 local BTFID 2 local BTFP1 local BTFType local SoundFile nil local RecurrentSound false local ALLOWEDSIDE local S -- Setup local T -- Trigger local CT -- Confirmed Trigger local lookBack local ShowAlert local Email local SendEmail local BaseSize function Prepare() -- Prepare all the data. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT --downArrow instance:createTextOutput (quotUpquot, quotUpquot, quotWingdings 3quot, 20, core. HCenter, core. VTop, instance. parameters. Bottom, 0) --upArrow instance:createTextOutput (quotDownquot, quotDownquot, quotWingdings 3quot, 20, core. HCenter, core. VBottom, instance. parameters. Top, 0) quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we dont check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(STRATTFID, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 BAR. open elseif Type quotHquot then P1 BAR. high elseif Type quotLquot then P1 BAR. low elseif Type quotMquot then P1 BAR. median elseif Type quotTquot then P1 BAR. typical elseif Type quotWquot then P1 BAR. weighted else P1 BAR. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id STRATTFID and period gt first then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if gBTFSource:size() gt 0 then local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) -- if we have enough bars in the history to work Signal (quotTP0 - START: btfPeriod(quot. tostring(btfPeriod). quot) gt first(quot. tostring(first). quot)quot ) if btfPeriod gt btfFirst then Signal (quotTP0a - quot. quotbtfPeriod gt btfFirstquot) -- This bit added for signalling only if BTFMAFlag then if gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end else BTFdir quotOffquot Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if BAR. close91period93 lt TrendMA. DATA91period93 then Signal (quotTP4 - trend Downquot) trendDdir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySound if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end There are only three sports: bullfighting, motor racing, and mountaineering all the rest are merely games. (c) Ernest Hemingway Hi Victor, Ive been correcting some of my typose too. This is getting really close now but problems still persist, this is now with line 295 as follows if gBTFSource. closebtfPeriod lt BTFTrendMA. DATAbtfPeriod then. the error is quotindex out of rangequot the values are as follows:- gBTFSource. close299 (1.44306) lt BTFTrendMA. DATA299 ( ) (btfFirst 199) I separated the two sides out into 2 lines as follows:- -- This works ok local y gBTFSource. closebtfPeriod -- this one gives ERROR INDEX OUT OF RANGE (does this line look right to you) local x BTFTrendMA. DATAbtfPeriod BTFTrendMA is created as follows: BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) Is there something wrong with this line if not Im Now out of ideas to track this further Full code here Code: Select all -- Intoduce the strategy to the host application (for example, Marketscope). -- The function is called once when the host application initially loads the strategy. function Init() strategy:name(quotLonNYBTFsignalquot) strategy:description(quotLonNY Bigger Time Frame Signalling Strategyquot) -- Fast and slow moving average parameters strategy. parameters:addGroup(quotMain Controlsquot) strategy. parameters:addString(quotTFquot, quotStrategy Time Framequot, quotquot, quotm5quot) strategy. parameters:setFlag(quotTFquot, core. FLAGPERIODS) strategy. parameters:addString(quotALLOWEDSIDEquot, quotAllowed sidequot, quotAllowed side for trading or signaling, can be Sell, Buy or Bothquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotBothquot, quotquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) strategy. parameters:addBoolean(quotSquot, quotSetup Alertquot, quotquot, false) strategy. parameters:addBoolean(quotTquot, quotTrigger Alertquot, quotquot, true) strategy. parameters:addBoolean(quotCTquot, quotConfirmed Trigger Alertquot, quotquot, false) strategy. parameters:addGroup(quotAlertsquot) strategy. parameters:addBoolean(quotShowAlertquot, quotShowAlertquot, quotquot, true) strategy. parameters:addBoolean(quotPlaySoundquot, quotPlay Soundquot, quotquot, true) strategy. parameters:addFile(quotSoundFilequot, quotSound Filequot, quotquot, quotquot) strategy. parameters:setFlag(quotSoundFilequot, core. FLAGSOUND) strategy. parameters:addBoolean(quotRecurrentSoundquot, quotRecurrent Soundquot, quotquot, true) strategy. parameters:addBoolean(quotSendEmailquot, quotSend Emailquot, quotquot, false) strategy. parameters:addString(quotEmailquot, quotEmailquot, quotquot, quotquot) strategy. parameters:setFlag(quotEmailquot, core. FLAGEMAIL) strategy. parameters:addGroup(quotCCI Parameterquot) strategy. parameters:addInteger(quotCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) strategy. parameters:addGroup(quotBigger Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotBTFMAFlagquot, quotBigger Time Frame MA Trend onquot, quotquot, true) strategy. parameters:addString(quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotBTFTypequot, quotBTFPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strategy. parameters:addString(quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) strategy. parameters:setFlag(quotBTFquot, core. FLAGPERIODS) strategy. parameters:addGroup(quotStrategy Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotStrategyMAFlagquot, quotStrategy MA Trend onquot, quotquot, true) strategy. parameters:addString(quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters:addGroup(quotLevelsquot) strategy. parameters:addInteger(quotOBquot, quotOverbought Levelquot, quotquot, 100) strategy. parameters:addInteger(quotOSquot, quot Oversold Levelquot, quotquot, -100) strategy. parameters:addInteger(quotOBCquot, quotOverbought Confirmation Levelquot, quotquot, 150) strategy. parameters:addInteger(quotOSCquot, quot Oversold Confirmation Levelquot, quotquot, -150) -- Price subscription parameters (bid or ask price, time frame) strategy. parameters:addGroup(quotPricequot) strategy. parameters:addString(quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotAskquot, quotquot, quotAskquot) -- The global variables local BAR nil -- the price history we subscribed for local first -- the index of the oldest period where we can check whether moving averages has been crossed local btfFirst local OB, OS, OBC, OSC local CCI local Top, Bottom local gBTFSource -- streams local BTFTrendMAMethod local BTFTrendMAPeriod local BTFTrendMA local BTFtrendDir local TrendMAMethod local TrendMAPeriod local TrendMA local trendDir local STRATTFID 1 local BTFID 2 local BTFP1 local BTFType local SoundFile nil local RecurrentSound false local ALLOWEDSIDE local S -- Setup local T -- Trigger local CT -- Confirmed Trigger local lookBack local ShowAlert local Email local SendEmail local BaseSize function Prepare() -- Prepare all the data. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we don-t check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(STRATTFID, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType BTFMAFlag instance. parameters. BTFMAFlag TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type MAFlag instance. parameters. MAFlag gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 BAR. open elseif Type quotHquot then P1 BAR. high elseif Type quotLquot then P1 BAR. low elseif Type quotMquot then P1 BAR. median elseif Type quotTquot then P1 BAR. typical elseif Type quotWquot then P1 BAR. weighted else P1 BAR. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id STRATTFID and period gt first then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if gBTFSource:size() gt 0 then local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) -- if we have enough bars in the history to work if btfPeriod gt btfFirst then -- This works ok local y gBTFSource. close91btfPeriod93 -- this one gives ERROR INDEX OUT OF RANGE local x BTFTrendMA. DATA91btfPeriod93 -- This bit added for signalling only if BTFMAFlag true then Signal(quotgBTFSource. close91quot. tostring(btfPeriod). quot93 (quot. tostring(gBTFSource. close91btfPeriod93). quot) lt BTFTrendMA. DATA91quot. tostring(btfPeriod). quot93 ( ) (btfFirst quot. tostring(btfFirst)) if gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then --Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then --Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end else BTFdir quotOffquot --Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if BAR. close91period93 lt TrendMA. DATA91period93 then -- Signal (quotTP4 - trend Downquot) trendDdir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then -- Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot --Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySound if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end
Comments
Post a Comment